home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3659 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  74 lines

  1. Path: familynews.cycor.ca!usenet
  2. From: gcaine@cycor.ca (gcaine)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Referances troubble
  5. Date: 23 Feb 1996 02:31:09 GMT
  6. Organization: Cycor Communications Inc., Coast to Coast Internet Services
  7. Message-ID: <1812.6626T1220T113@cycor.ca>
  8. References: <1266.6624T117T1455@himolde.no> <1143.6626T526T2599@cycor.ca>
  9. NNTP-Posting-Host: skt-as012.cycor.ca
  10. X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
  11.  
  12.  
  13. >First change Tester to this:
  14.  
  15. >void Tester(void *Testering)
  16. >{
  17. >    printf("%d\n", Testering); /* prints the address of Testering, which 
  18. >                                  hasn't been Allocated yet */
  19. >                                  
  20. >    if (Testering = AllocMem(100, MEMF_CHIP | MEMF_CLEAR))
  21. >    {
  22. >        printf("%d\n", Testering); /* prints the address of Testering */
  23. >        printf("%d\n", &Testering); /* prints the contents of Testering
  24. >                                       which is 0 */
  25. >    }
  26. >}
  27.  
  28. Stupid, stupid me !! 
  29.  
  30. That's all wrong.
  31.  
  32. First, printf("%d\n", &Testering will not print the contents of Testering,
  33. it will print the address of testering.
  34.  
  35. printf("%d\n", Testering); will not print the address of Testering, it will
  36. print rhe memory location Testering points to.
  37.  
  38. printf("%d\n", *Testering); Will print the contents of Testering.
  39.  
  40. Here's a little example of pointers that might help straighten things out
  41. for you.
  42.  
  43. --------------------------------Cut------------------------------
  44. #include <stdio.h>
  45.  
  46. void main(int argc, char *argv[])
  47. {
  48.     int someNumber;
  49.     int *pointer;
  50.     
  51.     someNumber = 10;
  52.     
  53.     pointer = &someNumber;
  54.     
  55.     printf("the address of someNumber is                %d\n", &someNumber);
  56.     printf("pointer contains the address of someNumber: %d\n", pointer);
  57.     
  58.     printf("someNumber hold the value                  %d\n", someNumber);
  59.     printf("You can also see the value with *pointer : %d\n", *pointer);
  60. }
  61.     
  62. ------------------------------End Cut---------------------------------
  63.  
  64. I believe for what you want to do, all you have to do is change
  65.  
  66. void Tester(&Testering) to
  67. void Tester(void *Testering)
  68.  
  69. I'm sorry about screwing up like that, I'll try to stop and think about
  70. what I'm saying next time.
  71.  
  72. Gary Caine    Member: Team AMIGA
  73.  
  74.